
function makeAtcgBar() {
        //atcg
        atcg = new THREE.Object3D();

        //plane
        var cubesPlaneGeometry = new THREE.PlaneGeometry(500, 500, 1, 0);
        var cubesPlaneMaterial = new THREE.MeshBasicMaterial({
            color : 0xc0c0c0,
            wireframe : false
        });
        var cubesPlane = new THREE.Mesh(cubesPlaneGeometry, cubesPlaneMaterial);
        atcg.add(cubesPlane);

        cubeGeometry = new THREE.CubeGeometry(200, 200, 50);
        textMaterial = new THREE.MeshBasicMaterial({
            color : 0x0000ff,
            wireframe : false
        });
        cubeMaterial = new THREE.MeshBasicMaterial({
            color : 0x0000ff,
            wireframe : true
        });


        positions = new Array();
        for (var i = 0; i < 4; i++) {
            /*
            //textMesh
            var letter = letters[i];

            var textGeo = new THREE.TextGeometry(letter, {
                size : 100,
                height : 20,
                face : "helvetiker"
            });
            textGeo.text = letter;
            textGeo.computeBoundingBox();

            var textMesh = new THREE.Mesh(textGeo, textMaterial.clone());
            textMesh.position.x = -40;
            textMesh.position.y = -40;

            //document.title += textGeo.text;

            //cubeMesh
            var cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial.clone());

            //node for cube & mesh
            var node = new THREE.Object3D();
            node.add(textMesh);
            node.add(cubeMesh);
            node.position.x = (i % 2) * 240 - 120;
            node.position.y = (1 - Math.floor(i / 2)) * 240 - 120;

            positions[i] = new THREE.Vector3(node.position.x, node.position.y, 0);

            atcg.add(node); //adding to atcg
            */
           // document.title += getLetter(node);
            var x = (i % 2) * 240 - 120;
            var y = (1 - Math.floor(i / 2)) * 240 - 120;
			var color;
			if(i==0 || i ==3 ){
			
            color = 0x0000ee;}
			else color=0x00ee00;
			
			
			
            makeCube2(letters[i], atcg, color, x, y);
        }

        atcg.position.x = ATCG_POS_X;
        atcg.position.y = ATCG_POS_Y;
        atcg.position.z = 100;

        scene.add(atcg); //adding atcg to the scene
    }

function makeDNAChain(){

    dnachain = new THREE.Object3D();

    for (var i = -5; i <= 10; i++){
        var sphereGeom = new THREE.SphereGeometry(10, 8, 8);
        var sphereMat = new THREE.MeshBasicMaterial({
            color : Math.random() * 0xffffff,
            wireframe : false
        });

        var sphere1 = new THREE.Mesh(sphereGeom, sphereMat);
        var sphere2 = new THREE.Mesh(sphereGeom, sphereMat);

        var r = 120;
        var s = 0.6;

        sphere1.position.x = Math.cos(i * s) * r;
        sphere1.position.y = i * 30;
        sphere1.position.z = Math.sin(i * s) * r;
        sphere2.position.x = Math.cos(i * s + Math.PI) * r;
        sphere2.position.y = i * 30;
        sphere2.position.z = Math.sin(i * s + Math.PI) * r;

        //spheres[i + 30] = sphere1;


        dnachain.add(sphere1);
        dnachain.add(sphere2);

        dnachain.position.x = CHAIN_POS_X;
        dnachain.position.y = CHAIN_POS_Y;
    }

    scene.add(dnachain);
}


function makeDNAPas(){

        pas = new THREE.Object3D();

        //plane
        var planeGeometry = new THREE.PlaneGeometry(220, 1000, 1, 0);
        var planeMaterial = new THREE.MeshBasicMaterial({
            color : 0xa0a0a0,
            wireframe : true
        });

        var plane = new THREE.Mesh(planeGeometry, planeMaterial);

        pas.add(plane);

        pas.position.x = PAS_POS_X;
        pas.position.y = PAS_POS_Y;

        scene.add(pas);
    }

//var randomLetters = ['A','A','A','A','A'];

function makeDNAPas2(){

        pas2 = new THREE.Object3D();

        //plane
        var planeGeometry = new THREE.PlaneGeometry(220, 1000, 1, 0);
        var planeMaterial = new THREE.MeshBasicMaterial({
            color : 0xa0a0a0,
            wireframe : true
        });

        var plane = new THREE.Mesh(planeGeometry, planeMaterial);

        pas2.add(plane);

        pas2.position.x = PAS2_POS_X;
        pas2.position.y = PAS2_POS_Y;


        for(var i = 0; i< ncubes; i++ ){
            var r = Math.floor(Math.random() * 4);
            var letter = letters[r];
            var color = 0xaaaaaa;
            makeCube2(letter, pas2, color, 0, i* 200 + 1000);
        }


        scene.add(pas2);
    }



function makeCube(letter, parent, x, y) {
        cubeGeometry = new THREE.CubeGeometry(200, 200, 50);
        textMaterial = new THREE.MeshBasicMaterial({
            color : 0x0000ff,
            wireframe : false
        });
        cubeMaterial = new THREE.MeshBasicMaterial({
            color : 0x0000ff,
            wireframe : true
        });


        var textGeo = new THREE.TextGeometry(letter, {
            size : 100,
            height : 20,
            face : "helvetiker"
        });
        textGeo.text = letter;
        textGeo.computeBoundingBox();

        var textMesh = new THREE.Mesh(textGeo, textMaterial.clone());
        textMesh.position.x = -40;
        textMesh.position.y = -40;

        //textMesh.geometry.text
        //cubeMesh
        var cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial.clone());

      //node for cube & mesh
        var node = new THREE.Object3D();
        node.add(textMesh);
        node.add(cubeMesh);
        node.position.x = x;
        node.position.y = y;

        parent.add(node);

        return node;
    }

function makeCube2(letter, parent, color, x, y) {

	var text1 = letter;
	var text2 = "";
	for (var i = 0; i < letter.length; i++) {
		var l = letter[i];
		if (l == ' ') {
			text1 = letter.substring(0, i);
			text2 = letter.substring(i + 1, letter.length);
		}
	}

	cubeGeometry = new THREE.CubeGeometry(200, 200, 20);
	textMaterial = new THREE.MeshBasicMaterial({
		color : 0xffffff, 
		transparent:true,
		opacity:0.8,//0x0000ff,
		wireframe : false
	});
	
	cubeMaterial = new THREE.MeshBasicMaterial({
		color : color,
		//opacity: 0.3,
		wireframe : false,
		transparent: true,
		opacity: 0.5
	});

	var cubeMaterial2 = new THREE.MeshBasicMaterial({
		color : 0x555555,
		//opacity: 0.3,
		wireframe : true
	});

	var textGeo1 = new THREE.TextGeometry(text1, {
		size : 40,
		height : 2,
		face : "helvetiker"
	});
	textGeo1.text = text1;
	textGeo1.computeBoundingBox();

	var textMesh1 = new THREE.Mesh(textGeo1, textMaterial.clone());
	textMesh1.position.x = -10;//-120;
	textMesh1.position.y = 0;
	textMesh1.position.z = 10;

	// textMesh.geometry.text
	// cubeMesh
	var cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial.clone());
var cubeMesh2 = new THREE.Mesh(cubeGeometry, cubeMaterial2.clone());
	cubeMesh2.position.x += 5;
	cubeMesh2.position.z +=10;

	// node for cube & mesh
	var node = new THREE.Object3D();
	node.add(textMesh1);
	node.add(cubeMesh);
	node.add(cubeMesh2);

	if (text2 != "") {
		var textGeo2 = new THREE.TextGeometry(text2, {
			size : 30,
			height : 3,
			face : "helvetiker"
		});
		textGeo2.text = text2;
		textGeo2.computeBoundingBox();

		var textMesh2 = new THREE.Mesh(textGeo2, textMaterial.clone());
		textMesh2.position.x = -95;
		textMesh2.position.y = -40;
	   textMesh2.position.z = 10;

		node.add(textMesh2);
	}

	node.position.x = x;
	node.position.y = y;
	parent.add(node);
	node.color = color;
	node.text = letter;
	return node;
}

function makeFinalMessage(){

    var message = new THREE.Object3D();

    //plane
    var planeGeometry = new THREE.PlaneGeometry(1200, 500, 1, 0);
    var planeMaterial = new THREE.MeshBasicMaterial({
        color : 0xc0c0c0,
        wireframe : false
    });
    var plane = new THREE.Mesh(planeGeometry, planeMaterial);
    message.add(plane);

    var textMaterial = new THREE.MeshBasicMaterial({
        color : 0x0000ff,
        wireframe : false
    });

    var textGeo = new THREE.TextGeometry('Good job!', {
        size : 100,
        height : 20,
        face : "helvetiker"
    });

    textGeo.computeBoundingBox();

    var textMesh = new THREE.Mesh(textGeo, textMaterial.clone());
    textMesh.position.x = -300;
    message.add(textMesh);

    message.position.z = 300;
    scene.add(message); //adding atcg to the scene

    dnachain.position.z = 400;

}

function createHydroConnection(parent, x, y, n) {
    cubeGeometry = new THREE.CubeGeometry(50, 20, 20);

    cubeMaterial = new THREE.MeshBasicMaterial({
        color :Math.random() * 0xffffff,
		wireframe : false,
		transparent: true,
		opacity: 0.5
    });


    var node = new THREE.Object3D();
    node.position.x = x + 100;
    node.position.y = y;
    node.position.z = 50;

    for(var i = 0; i < n; i++){
        var cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial.clone());
        cubeMesh.position.y = i * 30 - 30;
        node.add(cubeMesh);
        parent.add(node);
    }

    return node;
}
